package com.controller.medical;

import com.comm.R;
import com.service.medical.DrugService;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

@RestController
@RequestMapping("/medicine/message")
@Api(value = "药品进销存模块",tags = "药品信息维护的所有接口API")
@ApiResponses({
        @ApiResponse(code=200,message="请求成功"),
        @ApiResponse(code=404,message="找不到页面"),
        @ApiResponse(code=405,message="请求方法错误"),
        @ApiResponse(code=500,message="后台服务错误")
})
public class DrugController {

    @Resource
    private DrugService drugService;

    //查询药品信息
    @RequestMapping(value = "/findDrugList",method = RequestMethod.GET)
    @ApiOperation(value = "查询药品信息",notes = "查询药品信息",httpMethod = "GET", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "pageSize",value = "每页的条数",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "drugName",value = "药品名称",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "drugSort",value = "药品分类",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "status",value = "状态",paramType = "query",dataType = "int",required = false)
    })
    @ResponseBody
    public R findDrugList(int currentPage,int pageSize, String drugName, String drugSort,int status) {
        return drugService.findDrugList(currentPage,pageSize,drugName,drugSort,status);
    }

    //导入按钮
    @RequestMapping(value = "/addDrug",method = RequestMethod.POST)
    @ApiOperation(value = "导入按钮",notes = "导入按钮",httpMethod = "post", response = R.class)
    @ApiImplicitParam(name = "id",value = "药品id",paramType = "query",dataType = "int",required = true)
    @ResponseBody
    public R addDrug(int id) {

        return drugService.addDrug(id);
    }

    //删除药品信息
    @RequestMapping(value = "/deleteDrug",method = RequestMethod.POST)
    @ApiOperation(value = "删除药品信息",notes = "删除药品信息",httpMethod = "post", response = R.class)
    @ApiImplicitParam(name = "id",value = "药品id",paramType = "query",dataType = "int",required = true)
    @ResponseBody
    public R deleteDrug(int id) {

        return drugService.deleteDrug(id);
    }


}
